<template>
  <div class="customer-layer-box">
    <div class="customer-layer-content">
      <img class="width-35 height-35 layer-close" v-if="fileSpace" mode="widthFix"
            @click="closeEls" :src="fileSpace + '/images/w-icon-close.png'"/>
      <h2 class="font-23 font-white font-w"
        :style="'background: #fe773d url(' + fileSpace + '/images/w-cs-top.jpg) no-repeat'">客服</h2>
      <div v-if="info.workingTimeExplain" class="font-15 work-timer pad-t-16 pad-b-7 pad-l-15 pad-r-15">
        <p>{{ info.workingTimeExplain }}</p>
      </div>
      <div v-if="info.wechatNum"
        :class="!info.workingTimeExplain && info.wechatNum ? 'mar-t-15' : ''"
        class="flex v-align-c text-align-l layer-info-bar pad-l-20 pad-r-20 pad-t-5 pad-b-5 mar-l-15 mar-r-15 mar-b-10"
        @click="$pt.setClipboardData({data: info.wechatNum})">
        <span>客服微信：</span>
        <label class="flex-item mar-r-5">{{ info.wechatNum }}</label>
        <img class="width-20 height-20" v-if="fileSpace" mode="widthFix"
            :src="fileSpace + '/images/w-icon-copy.png'"/>
      </div>
      <div :class="!info.workingTimeExplain && !info.wechatNum ? 'pad-t-30 pad-b-21 mar-t-6' : ''">
        <div v-if="info.phone"
        class="flex v-align-c text-align-l layer-info-bar pad-l-20 pad-r-20 pad-t-5 pad-b-5 mar-l-15 mar-r-15"
          @click="$pt.makePhoneCall({phoneNumber: info.phone})">
          <span>客服电话：</span>
          <label class="flex-item mar-r-5">{{ info.phone }}</label>
          <img class="width-20 height-20" v-if="fileSpace" mode="widthFix"
              :src="fileSpace + '/images/w-icon-tel.png'"/>
        </div>
      </div>
      <div class="pad-t-15"></div>
    </div>
    <div class="customer-layer-bg" @click="closeEls"></div>
  </div>
</template>

<script>
  import { getEnterpriseByAppId } from '@/api/home'
  export default {
    data() {
      return {
        info: {}
      }
    },
    onLoad() {
      // 初始化data
      Object.assign(this.$data, this.$options.data())
    },
    onShow() {
      this.customerInfo()
    },
    mounted() {
      setTimeout(() => {
        this.customerInfo()
      }, 100)
    },
    methods: {
      customerInfo() {
        getEnterpriseByAppId().then((response) => {
          if (response.isError) return
          this.info = response.data
        }).catch(() => {
        })
      },
      closeEls() {
        this.$parent.layerBoolean = false
      }
    }
  }
</script>

<style scoped lang="less">  
  .customer-layer-content{
    position: fixed;
    left: 50%;
    top: 50%;
    width: 299px;
    margin: -115px 0 0 -150px;
    background: #fff;
    border-radius: 8px;
    z-index: 131;
    text-align: center;
    h2{
      width: 299px;
      height: 62px;
      line-height: 62px;
      background-size: 299px 62px!important;
      border-top-left-radius: 8px;
      border-top-right-radius: 8px;
    }
    .layer-close{
      position: absolute;
      left: 50%;
      bottom: -68px;
      margin: 0 0 0 -17px;
      z-index: 132;
    }
    .work-timer{
      min-height: 56px;
      box-sizing: border-box;
    }
    .layer-info-bar{
      background: #fff3f1;
      border-radius: 5px;
      label{
        width: 197px;
        height: 20px;
        line-height: 1.3;
        overflow:hidden;
        text-overflow:ellipsis;
        display:-webkit-box;
        -webkit-line-clamp:1;
        -webkit-box-orient:vertical;
        word-break:break-word;
      }
    }
  }
  .customer-layer-bg{
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 130;
    // background: rgba(0, 0, 0, 0.6);
  }
</style>
